package com.itheima.controller;

import com.itheima.dbservice.SsoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.Map;

@RestController
@RequestMapping("/user")
public class SsoController {
    @Autowired
    private SsoService ssoService;

    /**
     * 获取验证码
     * @param phoneMap
     * @return
     */
    @PostMapping("/login")
    public ResponseEntity login(@RequestBody Map<String, String> phoneMap){
        ssoService.sendCode(phoneMap);
        return ResponseEntity.ok(null);
    }

    /**
     * 验证码校验
     * @param map
     * @return
     */
    @PostMapping("/loginVerification")
    public ResponseEntity loginVerification(@RequestBody Map<String, String> map){
        return ResponseEntity.ok(ssoService.loginVerification(map));
    }

    @PostMapping("/loginReginfo/head")
    public ResponseEntity loginReginfoHead(@RequestHeader("Authorization")String token, MultipartFile headPhoto){
        ssoService.loginReginfoHead(token, headPhoto);
        return ResponseEntity.ok(null);
    }
}
